how to read the txt file from database(byte[] to filestream)

Posted by Ranjana on Stack Overflow See other posts from Stack Overflow or by Ranjana
Published on 2010-04-17T07:04:45Z Indexed on 2010/04/17 7:13 UTC
Read the original article Hit count: 276

Filed under:
|
|
|
|

i have stored the txt file to sql server database . i need to read the txt file line by line to get the content in it. my code :

DataTable dtDeleteFolderFile = new DataTable(); dtDeleteFolderFile = objutility.GetData("GetTxtFileonFileName", new object[] { ddlSelectFile.SelectedItem.Text }).Tables[0];

    foreach (DataRow dr in dtDeleteFolderFile.Rows)
    {
        name = dr["FileName"].ToString();
        records = Convert.ToInt32(dr["NoOfRecords"].ToString());
          bytes = (Byte[])dr["Data"];



    }

FileStream readfile = new FileStream(Server.MapPath("txtfiles/" + name), FileMode.Open);

  StreamReader streamreader = new StreamReader(readfile);

    string line = "";


    line = streamreader.ReadLine();

but here i have used the FileStream to read from the Particular path. but i have saved the txt file in byt format into my Database. how to read the txt file using the byte[] value to get the txt file content, instead of using the Path value.

© Stack Overflow or respective owner

Related posts about filestream

Related posts about c#